package com.um.jdy.common.member.util;

import cn.hutool.core.bean.BeanUtil;
import com.um.jdy.common.member.properties.MailSettingProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Slf4j
@Component
public class MailAccount {

    private static MailSettingProperties staticMailSettingProperties;

    @Autowired
    private MailSettingProperties mailSettingProperties;

    @PostConstruct
    public void init() {
        staticMailSettingProperties = mailSettingProperties;
    }

    private static cn.hutool.extra.mail.MailAccount instance;

    public static cn.hutool.extra.mail.MailAccount getInstance(){
        if (instance == null) {
            return BeanUtil.toBean(staticMailSettingProperties, cn.hutool.extra.mail.MailAccount.class);
        }
        return instance;
    }



}
